import 'package:flutter/material.dart';
import 'package:yw_bapp/model/store_detail_model.dart';
import 'package:yw_bapp/pages/first_page.dart';
import 'package:yw_bapp/pages/input_code.dart';
import 'package:yw_bapp/pages/merchant_info.dart';
import 'package:yw_bapp/pages/my_store.dart';
import 'package:yw_bapp/pages/phone_login.dart';
import 'package:yw_bapp/pages/store_select.dart';
import 'package:yw_bapp/provider/login_phone_provider.dart';
import 'package:yw_bapp/provider/manager_info_provider.dart';
import 'package:yw_bapp/provider/merchant_info_provider.dart';
import 'package:yw_bapp/provider/role_info_provider.dart';
import 'package:yw_bapp/provider/store_info_provider.dart';
import 'package:yw_bapp/provider/store_list_provider.dart';
import 'package:yw_bapp/widgets/file_picker_demo.dart';
import 'package:yw_bapp/widgets/safe_area_bar_widget.dart';
import 'package:yw_bapp/widgets/tip_pop_widget.dart';
import 'package:provider/provider.dart';

void main() {
  // runApp(MyApp());
  // runApp(ChangeNotifierProvider(
  //   create: (context) => MerchantInfoProvider(),
  //   child: MyApp(),
  // ));
  runApp(MultiProvider(
    providers: [
      ChangeNotifierProvider(
        create: (_) => MerchantInfoProvider(),
      ),
      ChangeNotifierProvider(
        create: (_) => LoginPhoneProvider(),
      ),
      ChangeNotifierProvider(
        create: (_) => StoreInfoProvider(),
      ),
      ChangeNotifierProvider(
        create: (_) => ManagerInfoProvider(),
      ),
      ChangeNotifierProvider(
        create: (_) => RoleInfoProvider(),
      ),
      ChangeNotifierProvider(
        create: (_) => StoreListProvider(),
      ),
    ],
    child: MyApp(),
  ));
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  final Color bkgColor = Color.fromARGB(255, 237, 88, 84);
  var topBar = new Container(
    // child: new Text('ABC'),
    color: Colors.blue,
  );
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
          visualDensity: VisualDensity.adaptivePlatformDensity,
        ),
        builder: (context, child) => Scaffold(
            body: GestureDetector(
          onTap: () {
            FocusScopeNode currentFocus = FocusScope.of(context);
            if (!currentFocus.hasPrimaryFocus &&
                currentFocus.focusedChild != null) {
              FocusManager.instance.primaryFocus.unfocus();
            }
          },
          child: child,
        )),
        home: MyStore(),
      );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}
